package com.niit.web.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.niit.service.NoteService;
import com.niit.service.QuestionService;
import com.niit.service.UserService;
import com.niit.service.impl.NoteServiceImpl;
import com.niit.service.impl.QuestionServiceImpl;
import com.niit.service.impl.UserServiceImpl;

@WebServlet("/AdminMainController")
public class AdminMainController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		NoteService ns = new NoteServiceImpl();
		UserService us = new UserServiceImpl();
		QuestionService qs = new QuestionServiceImpl();
		request.setAttribute("noteCount", ns.findTotal());
		request.setAttribute("userCount",us.findTotal());
		request.setAttribute("questionCount", qs.findTotal());
		request.getRequestDispatcher("/jsp/admin/backstage.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
